From: Juri Linkov Date: Sun, 29 Jul 2007 09:17:30 +0000 (+0000) Subject: (wdired-exit): New function. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~421^2~17600 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=d04e1bee8b2f66e19fea4850190e6d67c8d600e0;p=emacs.git (wdired-exit): New function. (wdired-mode-map): Bind C-x C-q to wdired-exit. --- diff --git a/lisp/wdired.el b/lisp/wdired.el index 0abb8647ce0..960d8990983 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -175,6 +175,7 @@ program `dired-chmod-program', which must exist." (define-key map "\C-c\C-c" 'wdired-finish-edit) (define-key map "\C-c\C-k" 'wdired-abort-changes) (define-key map "\C-c\C-[" 'wdired-abort-changes) + (define-key map "\C-x\C-q" 'wdired-exit) (define-key map "\C-m" 'ignore) (define-key map "\C-j" 'ignore) (define-key map "\C-o" 'ignore) @@ -423,6 +424,22 @@ non-nil means return old filename." (set-buffer-modified-p nil) (setq buffer-undo-list nil)) +(defun wdired-exit () + "Exit wdired and return to dired mode. +Just return to dired mode if there are no changes. Otherwise, +ask a yes-or-no question whether to save or cancel changes, +and proceed depending on the answer." + (interactive) + (if (buffer-modified-p) + (if (y-or-n-p (format "Buffer %s modified; save changes? " + (current-buffer))) + (wdired-finish-edit) + (wdired-abort-changes)) + (wdired-change-to-dired-mode) + (set-buffer-modified-p nil) + (setq buffer-undo-list nil) + (message "(No changes need to be saved)"))) + ;; Rename a file, searching it in a modified dired buffer, in order ;; to be able to use `dired-do-create-files-regexp' and get its ;; "benefits".